//
//  BenifitFilterCell.m
//  Finance
//
//  Created by cheng xiang on 13-8-6.
//  Copyright (c) 2013年 cheng xiang. All rights reserved.
//

#import "BenifitFilterCell.h"

@implementation BenifitFilterCell
@synthesize selectBtn = _selectBtn,title = _title,delegate = _delegate;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.textLabel.font = [UIFont boldSystemFontOfSize:15];
        
        _selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _selectBtn.frame = CGRectMake(110, 7, 90, 30);
        UIImage *btnImage = [UIImage imageNamed:@"cellbtnbg.png"];
        [_selectBtn setBackgroundImage:[btnImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)] forState:UIControlStateNormal];
        [_selectBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_selectBtn setTitle:@"不限" forState:UIControlStateNormal];
        [_selectBtn.titleLabel setFont:[UIFont systemFontOfSize:13]];
        [_selectBtn addTarget:self action:@selector(clickOnBtn) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_selectBtn];
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(210, 7, 20, 30)];
        [titleLabel setBackgroundColor:[UIColor clearColor]];
        titleLabel.text = @"%";
        titleLabel.font = [UIFont systemFontOfSize:13];
        [self addSubview:titleLabel];
    }
    return self;
}

- (void)clickOnBtn
{
    if ([_delegate respondsToSelector:@selector(clickOnBenifit:)]) {
        [_delegate clickOnBenifit:_selectBtn];
    }
}

- (void)setTitle:(NSString *)title
{
    _title = [title copy];
    if ([title isEqualToString:@"预期收益率"]) {
        self.textLabel.text = [NSString stringWithFormat:@"%@ >",_title];
        self.textLabel.font = [UIFont systemFontOfSize:13];
    }else{
        self.textLabel.text = [NSString stringWithFormat:@"%@",_title];
        self.textLabel.font = [UIFont systemFontOfSize:13];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
